package com.heima.admin.listener;

import com.baomidou.mybatisplus.annotation.TableId;
import com.heima.admin.service.IAuditService;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.stereotype.Service;

@Service
public class AuditListener {

    @Autowired
    private IAuditService iAuditService;

    @KafkaListener(topics="${topic.autoAuditTopic}")
    public void handleMessage(ConsumerRecord<String,String> record){
        String value = record.value();
        if (StringUtils.isNotEmpty(value)){
            iAuditService.auditById(Integer.parseInt(value));
        }
    }
}
